import React, { Component } from 'react'
// import qs from 'querystring'

export default class Detail extends Component {
  state = {
    data: [
      { id: '01', title:'消息1', content: '31省区市新增本土确诊65例' },
      { id: '02', title:'消息2', content: '神十三航天员圆满完成出舱任务' },
      { id: '03', title:'消息3', content: '叶光富迎翟志刚王亚平进舱 3人拥抱' }
    ]
  }
  render() {
    console.log(this.props)

    // 接收params参数
    const { id } = this.props.match.params

    // 接收search参数
    // const { id } = qs.parse(this.props.location.search.slice(1))

    // 接收state参数
    // const { id } = this.props.location.state

    const currentMsg = this.state.data.find(item => {
      return item.id === id
    })
    return (
      <div>
        <div>消息ID：{id}</div>
        <div>消息标题：{currentMsg.title}</div>
        <div>消息内容：{currentMsg.content}</div>
      </div>
    )
  }
}
